<!-- 继承公共的 form -->
{{extend name="../../../module/view/detail" /}}

<!-- 重写数据模块 -->
{{block name="detail_data"}}
    {{:ModuleInclude('public/detail_nav_switch_tabs', [
        'nav_data' => [
            [
                'name' => MyLang('form_base_data_title'),
                'key'  => 'base',
            ],
            [
                'name' => $goods_nav_list.video.name,
                'key'  => 'video',
            ],
            [
                'name' => $goods_nav_list.photo.name,
                'key'  => 'photo',
            ],
            [
                'name' => $goods_nav_list.spec.name,
                'key'  => 'spec',
            ],
            [
                'name' => $goods_nav_list.spec_images.name,
                'key'  => 'spec-images',
            ],
            [
                'name' => $goods_nav_list.parameters.name,
                'key'  => 'parameters',
            ],
            [
                'name' => $goods_nav_list.web.name,
                'key'  => 'web',
            ],
            [
                'name' => $goods_nav_list.app.name,
                'key'  => 'app',
            ],
            [
                'name' => $goods_nav_list.fictitious.name,
                'key'  => 'fictitious',
            ],
            [
                'name' => $goods_nav_list.seo.name,
                'key'  => 'seo-data-title',
            ]
        ]
    ])}}
    <div class="detail-content-switch-data-item">
        <!-- 父级内容 -->
        <div class="item am-active" data-key="base">
            {__block__}
        </div>

        <!-- 商品视频 -->
        <div class="item" data-key="video">
            {{if !empty($data['video'])}}
                <video src="{{$data.video}}" class="am-img-responsive" controls="controls" preload="auto">
                    your browser does not support the video tag
                </video>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- 商品相册 -->
        <div class="item" data-key="photo">
            {{if !empty($data['photo']) and is_array($data['photo'])}}
                <ul data-am-widget="gallery" class="am-gallery am-avg-sm-4 am-avg-md-4 am-avg-lg-4 am-gallery-default am-padding-0" data-am-gallery="{ pureview: true }">
                    {{foreach $data.photo as $k=>$v}}
                        <li class="am-padding-0 {{if $k gt 0}}am-margin-left-sm{{/if}}">
                            <div class="am-gallery-item am-nbfc">
                                <a href="javascript:;">
                                    <img src="{{$v.images}}" />
                                </a>
                            </div>
                        </li>
                    {{/foreach}}
                </ul>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- 商品规格 -->
        <div class="item" data-key="spec">
            {{if !empty($specifications) and is_array($specifications)}}
                <div class="am-scrollable-horizontal">
                    <table class="am-table am-table-bordered am-table-striped am-text-nowrap">
                        <thead>
                            <tr>
                                {{foreach $specifications.type as $line_k=>$line_v}}
                                    <th>{{$line_v.name}}</th>
                                {{/foreach}}
                                <th>{{:MyLang('common_service.goods.form_spec_thead_price_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_original_price_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_inventory_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_buy_min_number_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_buy_max_number_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_weight_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_volume_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_coding_title')}}</th>
                                <th>{{:MyLang('common_service.goods.form_spec_thead_barcode_title')}}</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{foreach $specifications.value as $line_k=>$line_v}}
                                <tr>
                                    {{foreach $line_v as $v}}
                                        {{if isset($v['data_type'])}}
                                            {{switch v.data_type}}
                                                {{case spec}}
                                                    <td class="am-text-middle">{{$v.data.value}}</td>
                                                {{/case}}

                                                {{case base}}
                                                    <td class="am-text-middle">{{if isset($v['data']['price'])}}{{$v.data.price}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['original_price']) and $v['data']['original_price'] gt 0}}{{$v.data.original_price}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['inventory'])}}{{$v.data.inventory}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['buy_min_number']) and $v['data']['buy_min_number'] 
                                                    gt 0}}{{$v.data.buy_min_number}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['buy_max_number']) and $v['data']['buy_max_number'] 
                                                    gt 0}}{{$v.data.buy_max_number}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['weight']) and $v['data']['weight'] 
                                                    gt 0}}{{$v.data.weight}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['volume']) and $v['data']['volume'] 
                                                    gt 0}}{{$v.data.volume}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['coding'])}}{{$v.data.coding}}{{/if}}</td>
                                                    <td class="am-text-middle">{{if isset($v['data']['barcode'])}}{{$v.data.barcode}}{{/if}}</td>
                                                {{/case}}
                                            {{/switch}}
                                        {{/if}}
                                    {{/foreach}}
                                </tr>
                            {{/foreach}}
                        </tbody>
                    </table>
                </div>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- 商品规格图片 -->
        <div class="item" data-key="spec-images">
            {{if !empty($specifications) and is_array($specifications)}}
                <ul data-am-widget="gallery" class="am-gallery am-avg-sm-4 am-avg-md-4 am-avg-lg-4 am-gallery-default am-padding-0" data-am-gallery="{ pureview: true }">
                    {{foreach $specifications.type as $line_k=>$line_v}}
                        {{foreach $line_v.value as $v}}
                            {{if !empty($v['images'])}}
                                <li>
                                    <div class="am-gallery-item">
                                        <a href="{{$v.images}}" target="_blank">
                                            <img src="{{$v.images}}" alt="{{$v.name}}"/>
                                            <h3 class="am-gallery-title am-text-center">{{$v.name}}</h3>
                                        </a>
                                    </div>
                                </li>
                            {{/if}}
                        {{/foreach}}
                    {{/foreach}}
                </ul>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- 商品参数 -->
        <div class="item" data-key="parameters">
            {{:ModuleInclude('public/goodsparamstemplate/detail')}}
        </div>

        <!-- 电脑端详情 -->
        <div class="item" data-key="web">
            {{if !empty($data['content_web'])}}
                <div class="am-nowrap-initial am-img-responsive">
                    {{$data.content_web|raw}}
                </div>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- 手机端详情 -->
        <div class="item" data-key="app">
            {{if !empty($data['content_app']) and is_array($data['content_app'])}}
                <div class="am-nowrap-initial am-img-responsive">
                    <ul>
                        {{foreach $data.content_app as $v}}
                            <li class="am-margin-bottom-sm">
                                <a href="{{$v.images}}" target="_blank">
                                    <img src="{{$v.images}}" />
                                </a>
                                {{if !empty($v['content']) and is_array($v['content'])}}
                                    <div class="am-margin-top-sm">
                                        {{foreach $v.content as $text}}
                                            <p>{{$text}}</p>
                                        {{/foreach}}
                                    </div>
                                {{/if}}
                            </li>
                        {{/foreach}}
                    </ul>
                </div>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- 虚拟商品展示数据 -->
        <div class="item" data-key="fictitious">
            {{if !empty($data['fictitious_goods_value'])}}
                <div class="am-nowrap-initial am-img-responsive">
                    {{$data.fictitious_goods_value|raw}}
                </div>
            {{else /}}
                {{:ModuleInclude('public/not_data')}}
            {{/if}}
        </div>

        <!-- SEO信息 -->
        {{:ModuleInclude('lib/seo_data')}}
    </div>
{{/block}}